<?php
class Req_sfsCJ {
	const url = "http://127.0.0.1:38899/ChouJiang/lobbyHandler";
	static function http_post_data($url, $data_string) {
		$ch = curl_init ( $url );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
		curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data_string );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 5 );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
				'Content-Type: application/json',
				'Content-Length: ' . strlen ( $data_string ) 
		) );
		$data = curl_exec ( $ch );
		return $data;
	}
	/**
	 * 获取配置
	 *
	 * @return unknown （返回数据：机台通信，房间名）
	 */
	function GetConfig() {
		$arr = array (
				'req' => '1' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 提交设置
	 *
	 * @param unknown $conn
	 *        	机台通讯
	 * @param unknown $name
	 *        	房间名
	 * @param unknown $status
	 *        	状态（0：开，1：关，2：隐藏）
	 * @return mixed
	 */
	function SetConfig($conn, $name, $status) {
		$arr = array (
				'req' => '2',
				'1' => $conn,
				'2' => $name,
				'3' => $status 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获取配置
	 *
	 * @return unknown （返回数据：ID，奖项名，奖值，获奖次数）
	 */
	function GetAwardsConfig() {
		$arr = array (
				'req' => '3' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 *
	 * @param unknown $id
	 *        	奖项ID
	 * @param unknown $name
	 *        	奖项名
	 * @param unknown $value
	 *        	奖值
	 * @param unknown $count
	 *        	获奖次数
	 * @return mixed 返回成功或失败
	 */
	function SetAwardsConfig($id, $name, $value, $count) {
		$arr = array (
				'req' => '4',
				'1' => $id,
				'2' => $name,
				'3' => $value,
				'4' => $count 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 添加奖项配置
	 *
	 * @param unknown $name
	 *        	奖项名
	 * @param unknown $value
	 *        	奖值
	 * @param unknown $count
	 *        	获奖次数
	 * @return mixed 返回成功或失败
	 */
	function AddConfig($id, $name, $value, $count) {
		$arr = array (
				'req' => '5',
				'1' => $id,
				'2' => $name,
				'3' => $value,
				'4' => $count 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 删除奖项配置
	 *
	 * @return mixed 返回成功或失败
	 */
	function DeleteConfig($id) {
		$arr = array (
				'req' => '6',
				'1' => $id 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获取申请列表
	 *
	 * @return mixed 返回：玩家ID，申请时间
	 */
	function GetApplyList() {
		$arr = array (
				'req' => '7' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 处理玩家申请
	 *
	 * @param unknown $name
	 *        	玩家ID
	 * @param unknown $result
	 *        	结果（0：拒绝，1：同意）
	 * @return mixed 返回成功或失败
	 */
	function HandleApplyMsg($name, $result) {
		$arr = array (
				'req' => '8',
				'1' => $name,
				'2' => $result 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获取中将明细
	 *
	 * @param unknown $type
	 *        	搜索类型
	 * @param unknown $key
	 *        	搜索关键字
	 * @param unknown $start
	 *        	开始时间
	 * @param unknown $end
	 *        	结束时间
	 * @return mixed 返回ID,当前座位号，奖项名，奖值
	 */
	function GetAwardsDetail($type, $key, $start, $end) {
		$arr = array (
				'req' => '9',
				'1' => $type,
				'2' => $key,
				'3' => $start,
				'4' => $end 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获取房间信息
	 *
	 * @return mixed 返回座位号，玩家ID，当前分数，邀请码
	 */
	function GetRoomInfo() {
		$arr = array (
				'req' => '10' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 抽奖
	 *
	 * @param unknown $awardId
	 *        	奖项ID
	 * @param unknown $seatId
	 *        	座位号
	 * @return mixed 成功/失败
	 */
	function LotteryAwards($awardId, $seatId) {
		$arr = array (
				'req' => '11',
				'1' => $awardId,
				'2' => $seatId 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 开始抽奖
	 *
	 * @return mixed 成功/失败
	 */
	function BeginLottery() {
		$arr = array (
				'req' => '12' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获奖明细
	 *
	 * @return mixed
	 */
	function GetAwardsList() {
		$arr = array (
				'req' => '13' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 停止转动
	 *
	 * @param unknown $awardId        	
	 * @return mixed
	 */
	function StopLottery($seatId) {
		$arr = array (
				'req' => '14',
				'1' => $seatId 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 添加抽奖名单
	 *
	 * @return mixed
	 */
	function AddLotteryPlayer($id) {
		$arr = array (
				'req' => '15',
				'1' => $id 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 获奖抽奖名单
	 *
	 * @return mixed
	 */
	function GetLotteryList() {
		$arr = array (
				'req' => '16' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 *
	 * @param unknown $id        	
	 * @return mixed
	 */
	function RemoveLotteryPlayer($id) {
		$arr = array (
				'req' => '17',
				'1' => $id 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	function GetTodayLotteryAward() {
		$arr = array (
				'req' => '18' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsCJ::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 用户上分通知
	 *
	 * @return mixed
	 */
	function UserTopUp($name, $coin) {
		$arr = array (
				'req' => '19',
				'1' => $name,
				'2' => $coin 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsMPZZ2::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 总送出
	 * 
	 * @return mixed
	 */
	function AllSendOut() {
		$arr = array (
				'req' => '20' 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsMPZZ2::http_post_data ( Req_sfsCJ::url, $json_string );
	}
	/**
	 * 统计出玩家账号
	 * 
	 * @param string[] $names        	
	 * @return mixed
	 */
	function StatisticsLotteryList($names) {
		$arr = array (
				'req' => '22',
				'1' => $names 
		);
		$json_string = json_encode ( $arr );
		return Req_sfsMPZZ2::http_post_data ( Req_sfsCJ::url, $json_string );
	}
}
